FROM centos:centos7.9.2009

RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
#    && rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm \
    && yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm -y \
    && yum install -y yum-utils pcre2-devel && yum-config-manager --disable 'remi-php*' \
    && yum-config-manager --enable  remi-php55 \
    && yum install -y gcc gcc-c++ make wget git unzip zlib-devel \
    && wget --no-check-certificate https://jaist.dl.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.zip -O pcre-8.45.zip \
    && unzip pcre-8.45.zip && cd pcre-8.45 && ./configure && make && make install && cd .. \
    && yum install -y php php-bcmath php-dom php-gd php-imagick php-intl php-fpm php-ioncube-loader php-mbstring php-mcrypt \
    php-mysqlnd php-pdo php-opcache php-pecl-memcache php-pecl-memcached php-pecl-redis php-pecl-xdebug \
    php-soap php-xmlrpc \
    # php \
    && wget --no-check-certificate https://getcomposer.org/composer-1.phar -O /root/composer.phar \
    && cp /root/composer.phar /bin/composer && chmod +x /bin/composer \
    && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ \
    # nginx \
    && wget --no-check-certificate http://tengine.taobao.org/download/tengine-2.2.3.tar.gz -O tengine-2.2.3.tar.gz \
    && wget --no-check-certificate https://www.openssl.org/source/old/1.0.2/openssl-1.0.2j.tar.gz -O openssl-1.0.2j.tar.gz \
    && tar xf openssl-1.0.2j.tar.gz \
    && tar xf tengine-2.2.3.tar.gz && cd tengine-2.2.3 \
    && ./configure --prefix=/usr/local/tengine --user=apache \
    --group=apache --with-http_v2_module --with-http_ssl_module --with-http_gzip_static_module  \
    --with-http_realip_module --with-http_flv_module --with-http_mp4_module \
    --with-http_concat_module=shared --with-http_sysguard_module=shared \
    --with-openssl=../openssl-1.0.2j --with-pcre-jit \
    && make && make install \
    && ln -s /usr/local/tengine/sbin/nginx /usr/local/bin/nginx \
    && make && make install \
    && cd .. && rm -fr openssl-1.0.2j*  tengine-2.2.3* pcre-8* \
    && mkdir -p /usr/local/tengine/conf/vhost \
    && yum clean all \
    && echo "#!/bin/bash" > bootstrap.sh \
    && echo "php-fpm -c /etc/php-fpm.conf" >> bootstrap.sh \
    && echo 'nginx -g "daemon off;"' >> bootstrap.sh \
    && chmod +x bootstrap.sh
ENTRYPOINT ["./bootstrap.sh"]